<%@ page contentType="text/html;charset=UTF-8" %>
<%@ taglib prefix="uct" uri="/WEB-INF/uct.tld" %>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
  <meta charset="utf-8">
  <meta http-equiv="X-UA-Compatible" content="IE=edge">
  <%@ include file="/common/plateform/common-js.jsp"%>
  <%@ include file="/common/plateform/common-css.jsp"%>	
  <title>WHQ | 基础平台</title>
  <!-- Tell the browser to be responsive to screen width -->
  <meta content="width=device-width, initial-scale=1, maximum-scale=1, user-scalable=no" name="viewport">
</head>
<body class="hold-transition skin-blue sidebar-mini">
<div class="wrapper">
  <!-- top start -->
  <%@include file="/common/plateform/top.jsp" %>
  <!-- top end -->
  <!-- left start -->
  <%@include file="/common/plateform/left.jsp" %>
  <!-- left end-->
  <div class="content-wrapper">
  		<br/>
		<ol class="breadcrumb bgblue">
			<li>
				<span class="label label-danger font14" >机构与用户管理 / 用户回收管理</span>
			</li>
		</ol>
    <!-- Main start -->
<section class="content">
      <div class="row">
        <div class="col-xs-12">
          <div class="box">
            <!-- /.box-header -->
            <div class="box-body">
            <center>
				<form id="searchFrom" class="form-horizontal">
				<input type="hidden" name="doCode" value="userList"/>
				<input type="hidden" name="userStatus" value="-1"/>
				</form>
				</center>
            
              <table id="example" class="table table-bordered table-hover" >
                <thead>
                <tr>
                  <th>用户账号</th>
                  <th>用户姓名</th>
                  <th>所属机构</th>
                  <th>所属部门</th>
                  <th>用户类型</th>
                  <th>性别</th>
                  <th>手机</th>
                  <th>操作</th>
                </tr>
                </thead>
                <tbody id="myList">
                </tbody>
              </table>
         	    <center>
    	  			  <ul id="pageList"></ul>
        		</center>
            </div>
          </div>
        </div>
      </div>
    </section>
    <!-- Main end -->
  </div>
  <!-- /.content-wrapper -->
  <!-- foot start -->
       
  <%@include file="/common/plateform/foot.jsp" %>
  <!-- foot start -->
  <!-- right start -->
  <%@include file="/common/plateform/right.jsp" %>
  <!-- right start -->
</div>    
</body>
	<script type="text/template" id="dataList">
	  		<? for ( var i = 0; i < rows.length; i++) {?>
				<tr>
					<td style="display:none;"><?=rows[i].userId?></td>
					<td><?=rows[i].userCname?></td>
					<td><?=rows[i].userEname?></td>
					<td><?=rows[i].orgEname?></td>
					<td><?=rows[i].deptName?></td>
					<td><?=rows[i].userType?></td>
					<td><?=rows[i].userSex?></td>
					<td><?=rows[i].mobile?></td>
					<td><a href="javascript:void(0)" onclick="del('<?=rows[i].userId?>')">删除</a> | 
                        <a href="javascript:void(0)" onclick="resUser('<?=rows[i].userId?>')">恢复</a>
                    </td>
				</tr>
     		<?}?>
	</script>

<script>
var clickMenu= 'user-gc';
var del_url = "${ctx}/res/uct/admin/delUser";
var res_url = "${ctx}/res/uct/admin/saveUser";
var id;
$(function () {
	getTableData();
	$('#example tbody').on('click','tr', function (e) {
	     if ( $(this).hasClass('selected') ) {
	            //$(this).removeClass('selected');
	        } else {
	            $('tr.selected').removeClass('selected');
	            $(this).addClass('selected');
	        }
	     id = $('tr.selected td').eq(0).html();
	   //  console.log($('tr.selected td').eq(1).html())
	} );
  });
  
//设置模态框隐藏事件钩子  
$( '#my_modal' ).on( 'hide.bs.modal' ,function(e){  
	cleanData('userFormData');
}); 

//设置模态框隐藏事件钩子  
$( '#my_modal' ).on( 'show.bs.modal' ,function(e){  
	$.ajax({
	    type:'get',
	    url:'${ctx}/sendPage/token?token=true',
	    dataType:'json',
	    success: function(myData){
	    	//console.log(myData);
			 $('#formToken').val(myData);
	  	}
	});	
}); 

function cleanData(id){
	$(':input','#'+id)  
	 .not(':button, :submit, :reset, :hidden')  
	 .val('')  
	 //.removeAttr('checked')  
	 .removeAttr('selected'); 
}

function getTableData(){
	deleteAllRow('example');
	var utrlss="${ctx}/trans/list/";
	$.ajax({
		   type:'get',
		   url:utrlss,//user_search_url,
		   data:$('#searchFrom').serialize()+getCurrentPage(utrlss+"?"+$('#searchFrom').serialize(),8),
		   dataType:'json',
		   success: function(myData){
			var data = baidu.template('dataList',eval(myData));  
			$("#myList").html(data);
			  var option= {
					   ele:$("#pageList")[0],
					   total:myData.total,
					   fn:getTableData,
					   url:user_search_url+"?"+$('#searchFrom').serialize()
				   }
			generatePages(option);
		   }
		});	
  }

function deleteAllRow(tableId){
	var tb = document.getElementById(tableId);
	if(tb){
	     var rowNum=tb.rows.length;
	     for (var i=1;i<rowNum;i++){
	         tb.deleteRow(i);
	         rowNum=rowNum-1;
	         i=i-1;
	     }
     }
}

function del(userId){
	layer.confirm('您确定要删除该用户信息？', { btn: ['确定','取消'] //按钮
		}, function(){
			$.ajax({ type:'post', url:del_url, data:{'userId':userId,'isDelete':'true'},
			    dataType:'json',
			    success: function(myData){
			    	layer.alert(myData.msg, {skin: 'layui-layer-molv',closeBtn: 0 });
			    	if(myData.flag=='T'){
			    		refresh();
			    	}
			  	}
			});	
		});
}

function resUser(userId){
	layer.confirm('您确定要恢复该用户信息？', { btn: ['确定','取消'] //按钮
		}, function(){
			$.ajax({ type:'post', url:res_url, data:{'userId':userId,'userStatus':'1'},
			    dataType:'json',
			    success: function(myData){
			    	layer.alert(myData.msg, {skin: 'layui-layer-molv',closeBtn: 0 });
			    	if(myData.flag=='T'){
			    		refresh();
			    	}
			  	}
			});	
		});
}

function cannel(modalId){
	$('#'+modalId).modal('hide');
}

function refresh(){
    //window.location.reload();
	getTableData();
}
</script>
</html>
